﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Squadron.CanvasData
{
    public class AddinView
    {
        public SquadronAddin Addin { get; set; }

        public override string ToString()
        {
            return GetDataFormat(Addin);
        }

        private string GetDataFormat(SquadronAddin addin)
        {
            if (addin.UserControlType != null)
            {
                foreach (Control control in SquadronContext.Utils.GetControlsRecursively(addin.UserControlInstance))
                {
                    if (control is DataGridView)
                    {
                        addin.DataControl = control;

                        return addin.Name + " (Grid with " + SquadronContext.Utils.GetRowCount(control as DataGridView).ToString() + " rows)";
                    }
                }
            }

            return addin.Name + " (No Data)";
        }
    }
}
